package main;

import com.sun.org.apache.xpath.internal.operations.Mod;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

public class Java_Shangji_1 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class clz = Class.forName("entity.Person");
        String fullName = clz.getName();
        String simpleName = clz.getSimpleName();
        System.out.println(fullName+"的基本信息");;
        System.out.println("------------------------------------");
        Package pkg = clz.getPackage();
        System.out.println(simpleName+"定义在"+pkg.getName()+"包中");
        System.out.println("------------------------------------");
        Class superClass = clz.getSuperclass();
        System.out.println(simpleName+"类的父类是:"+superClass.getName());
        System.out.println("------------------------------------");
        Class[] interfaces = clz.getInterfaces();
        System.out.println(simpleName+"所实现的接口");
        for (Class c :interfaces){
            System.out.println("\t"+c.getName());
            System.out.println("------------------------------------");
        }

        System.out.println(simpleName+"的修饰符:");
            int modifier = clz.getModifiers();
            if ((modifier & Modifier.PUBLIC)==Modifier.PUBLIC){
                System.out.println("public");
            }else if((modifier & Modifier.PROTECTED)==Modifier.PROTECTED){
                System.out.println("protected");
            }else if ((modifier & Modifier.PRIVATE)==Modifier.PRIVATE){
                System.out.println("private");
            }else {
                System.out.println("default(package)");
            }
    }
}
